<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div getTime="20" data-index="15"></div>
    <script>
        var div = document.querySelector('div');
        console.log(div.getTime);
        console.log(div.getAttribute('getTime'));
        console.log(div.getAttribute('data-index'));

        //h5新增的获取自定义属性的方法
        console.log(div.dataset.index);
    </script>
</body>
</html>